package com.asohofrucol.dao;


import java.util.List;

import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.transaction.annotation.Transactional;


import com.asohofrucol.model.DealTechnicalAssistanceVisit;

public interface DealTechnicalAssistanceVisitDao extends
BasicSaveDao<DealTechnicalAssistanceVisit, Long>{
	@Query("SELECT p FROM DealTechnicalAssistanceVisit p WHERE p.dealTechnicalAssistance.id = :technicalAssistanceId order by p.visitDate" )
	public List<DealTechnicalAssistanceVisit> listByDealTechnicalAssistance(
			@Param("technicalAssistanceId") Long technicalAssistanceId);
	
	@Modifying
	@Query("UPDATE DealTechnicalAssistanceVisit p SET p.evidenceFileName =:fileName WHERE p.id =:technicalAssistanceVisitId" )
	@Transactional
	public void saveEvidenceFileName(@Param("technicalAssistanceVisitId") Long technicalAssistanceVisitId,@Param("fileName") String fileName);
}
